
 package com.ami.kvm.jviewer.gui;
 
 import com.ami.kvm.jviewer.Debug;
 import com.ami.kvm.jviewer.JViewer;
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.Point;
 import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.net.URL;
 import java.util.Timer;
 import java.util.TimerTask;
 import javax.swing.Box;
 import javax.swing.BoxLayout;
 import javax.swing.ImageIcon;
 import javax.swing.JButton;
 import javax.swing.JComponent;
 import javax.swing.JDialog;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
 import javax.swing.event.PopupMenuEvent;
 import javax.swing.event.PopupMenuListener;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 public class FSMenuBar
   extends JDialog
 {
   private static final long serialVersionUID = 1L;
   private static final String PIN = "Pin";
   private static final String UNPIN = "Unpin";
   private static final String MENU = LocaleStrings.getString("B_2_FMB");
   private static final String LED_STATUS = "LED Status";
   private static final String MINIMIZE = LocaleStrings.getString("B_4_FMB");
   private static final String TO_FRAME = LocaleStrings.getString("B_5_FMB");
   private static final String CLOSE = LocaleStrings.getString("B_6_FMB");
   
   private static final int MENUBAR_HEIGHT = 20;
   private FSFrame m_frame;
   private FSMenu m_fsMenu;
   private JPopupMenu m_popupMenu;
   private MouseEnterExit m_msEE;
   private ButtonListener m_btnListener;
   private int m_slide = 0;
   private int slideStatusBar = 0;
   private int m_fsMenuX;
   private int m_fsMenuY;
   private int m_fsMenuWidth;
   private Timer m_timer;
   private Timer ledStatusTimer;
   private boolean m_show;
   private boolean showLEDStatusBar = false;
   private JComponent m_contentPane;
   private JLabel m_idLbl;
   private JButton m_menuBtn;
   private JPanel m_autoPanel;
   private JButton m_autoPin;
   private JButton m_autoUnpin;
   private JButton showLEDStatus;
   private FSLEDStatusBar ledStatusBar;
   private boolean m_auto;
   private boolean fsToolbarEnabled = false;
   
 
 
 
 
 
   public FSMenuBar() {}
   
 
 
 
 
   public FSMenuBar(FSFrame paramFSFrame)
   {
     super(JViewer.getMainFrame());
     this.ledStatusBar = new FSLEDStatusBar(this);
     Dimension localDimension = Toolkit.getDefaultToolkit().getScreenSize();
     this.m_fsMenuWidth = 400;
     this.m_fsMenuX = ((localDimension.width - this.m_fsMenuWidth) / 2);
     setBounds(this.m_fsMenuX, 0, this.m_fsMenuWidth, this.m_slide);
     setVisible(false);
     setUndecorated(true);
     setResizable(false);
     setFocusable(false);
     setFocusableWindowState(false);
     this.m_msEE = new MouseEnterExit();
     addMouseListener(this.m_msEE);
     addMouseListener(new WindowMouseEvents());
     this.m_btnListener = new ButtonListener();
     this.m_contentPane = ((JComponent)getContentPane());
     this.m_contentPane.setBackground(new Color(250, 250, 250));
     this.m_contentPane.setLayout(new BoxLayout(this.m_contentPane, 0));
     this.m_contentPane.add(Box.createRigidArea(new Dimension(5, 0)));
     this.m_autoPin = createButton("res/pin.jpg", LocaleStrings.getString("B_1_FMB"), "Pin");
     this.m_autoUnpin = createButton("res/unpin.jpg", LocaleStrings.getString("B_1_FMB"), "Unpin");
     this.m_autoPanel = new JPanel();
     this.m_autoPanel.setLayout(new BoxLayout(this.m_autoPanel, 0));
     this.m_autoPanel.setPreferredSize(new Dimension(15, 15));
     this.m_autoPanel.setMaximumSize(new Dimension(15, 15));
     this.m_autoPanel.add(this.m_autoPin);
     this.m_auto = false;
     this.m_contentPane.add(this.m_autoPanel);
     
     this.m_contentPane.add(Box.createRigidArea(new Dimension(5, 0)));
     this.m_menuBtn = createButton("res/menu.jpg", MENU, MENU);
     this.m_fsMenu = new FSMenu();
     this.m_popupMenu = this.m_fsMenu.getPopupMenu();
     this.m_popupMenu.addPopupMenuListener(new PopupMenuEventListener());
     this.m_menuBtn.addMouseListener(new PopupListener());
     this.m_contentPane.add(this.m_menuBtn);
     
     this.m_contentPane.add(Box.createRigidArea(new Dimension(5, 0)));
     this.showLEDStatus = createButton("res/lock.png", LocaleStrings.getString("B_7_FMB"), "LED Status");
     this.m_contentPane.add(this.showLEDStatus);
     this.m_contentPane.add(Box.createRigidArea(new Dimension(5, 0)));
     
     this.m_contentPane.add(createSeparator());
     
     this.m_contentPane.add(Box.createRigidArea(new Dimension(5, 0)));
     this.m_idLbl = new JLabel(LocaleStrings.getString("B_3_FMB"));
     this.m_idLbl.setForeground(new Color(0, 100, 100));
     this.m_idLbl.setFont(new Font("SansSerif", 0, 12));
     this.m_idLbl.setHorizontalAlignment(0);
     this.m_idLbl.setPreferredSize(new Dimension(287, 15));
     this.m_idLbl.setMinimumSize(new Dimension(287, 15));
     this.m_idLbl.setMaximumSize(new Dimension(287, 15));
     this.m_contentPane.add(this.m_idLbl);
     
     this.m_contentPane.add(Box.createRigidArea(new Dimension(5, 0)));
     this.m_contentPane.add(createButton("res/min.jpg", MINIMIZE, MINIMIZE));
     this.m_contentPane.add(Box.createRigidArea(new Dimension(1, 0)));
     this.m_contentPane.add(createButton("res/max.jpg", TO_FRAME, TO_FRAME));
     this.m_contentPane.add(Box.createRigidArea(new Dimension(1, 0)));
     this.m_contentPane.add(createButton("res/close.jpg", CLOSE, CLOSE));
   }
   
 
 
 
 
 
   public JVMenu getFSMenu()
   {
     return this.m_fsMenu;
   }
   
 
 
   public FSLEDStatusBar getLedStatusBar()
   {
     return this.ledStatusBar;
   }
   
 
 
 
 
   public void showMenu()
   {
     this.m_show = true;
     if (this.m_timer != null)
       this.m_timer.cancel();
     this.m_timer = new Timer();
     this.m_timer.schedule(new SlideTask(), 0L, 20L);
     if (this.fsToolbarEnabled) {
       showLEDStatusBar(true);
     }
   }
   
 
 
 
   public void hideMenu()
   {
     this.m_show = false;
     if (this.m_timer != null)
       this.m_timer.cancel();
     this.m_timer = new Timer();
     this.m_timer.schedule(new SlideTask(), 0L, 20L);
     if (this.fsToolbarEnabled) {
       showLEDStatusBar(false);
     }
   }
   
 
 
 
 
 
 
 
   public void setIDLabel(String paramString)
   {
     int j = 15;
     int k = JViewerApp.getInstance().getWindowPostionToSet().x;
     Dimension localDimension = JViewerApp.getInstance().getCurrentMonitorResolution();
     int i;
     if (System.getProperty("os.name").startsWith("Mac")) {
       i = 199;
       this.m_fsMenuWidth = 332;
       this.m_fsMenuX = (k + (localDimension.width - this.m_fsMenuWidth) / 2);
       this.m_fsMenuY = 20;
     }
     else {
       i = 187;
       this.m_fsMenuWidth = 320;
       this.m_fsMenuX = (k + (localDimension.width / 2 - this.m_fsMenuWidth / 2));
       this.m_fsMenuY = 0;
     }
     
     this.m_idLbl.setPreferredSize(new Dimension(i, j));
     this.m_idLbl.setMinimumSize(new Dimension(i, j));
     this.m_idLbl.setMaximumSize(new Dimension(i, j));
     this.m_idLbl.setText(paramString);
     setBounds(this.m_fsMenuX, this.m_fsMenuY, this.m_fsMenuWidth, this.m_slide);
   }
   
 
 
   public void cancelTimer()
   {
     if (this.m_timer != null)
     {
       this.m_timer.cancel();
       this.m_timer = null;
     }
     if (this.ledStatusTimer != null)
     {
       this.ledStatusTimer.cancel();
       this.ledStatusTimer = null;
     }
   }
   
 
 
 
   private void showLEDStatusBar(boolean paramBoolean)
   {
     this.showLEDStatusBar = paramBoolean;
     if (this.ledStatusTimer != null) {
       this.ledStatusTimer.cancel();
     }
     this.ledStatusTimer = new Timer();
     this.ledStatusTimer.schedule(new StatusBarSlideTask(), 0L, 20L);
   }
   
 
 
 
   private void slide()
   {
     if (System.getProperty("os.name").startsWith("Mac")) {
       setBounds(this.m_fsMenuX, 20, this.m_fsMenuWidth, this.m_slide);
     } else
       setBounds(this.m_fsMenuX, 0, this.m_fsMenuWidth, this.m_slide);
     if (this.showLEDStatusBar)
       slideStatusBar();
     setVisible(true);
   }
   
 
 
 
   private void slideStatusBar()
   {
     if (this.slideStatusBar < 20) {
       int i = this.m_fsMenuX + (this.m_fsMenuWidth - 160) / 2;
       if (System.getProperty("os.name").startsWith("Mac")) {
         this.ledStatusBar.setBounds(i, this.m_slide + 20, 160, this.slideStatusBar);
       } else
         this.ledStatusBar.setBounds(i, this.m_slide, 160, this.slideStatusBar);
       this.ledStatusBar.setVisible(true);
     }
   }
   
 
 
 
   private JButton createButton(String paramString1, String paramString2, String paramString3)
   {
     URL localURL = JViewer.class.getResource(paramString1);
     JButton localJButton = new JButton();
     if (localURL != null) {
       localJButton.setIcon(new ImageIcon(localURL));
     }
     
     localJButton.setToolTipText(paramString2);
     localJButton.setPreferredSize(new Dimension(15, 15));
     localJButton.setMinimumSize(new Dimension(15, 15));
     localJButton.setMaximumSize(new Dimension(15, 15));
     localJButton.addMouseListener(this.m_msEE);
     localJButton.setActionCommand(paramString3);
     localJButton.addActionListener(this.m_btnListener);
     return localJButton;
   }
   
 
 
   private JLabel createSeparator()
   {
     JLabel localJLabel = new JLabel("|");
     localJLabel.setForeground(new Color(200, 200, 200));
     localJLabel.setFont(new Font("Arial", 0, 18));
     return localJLabel;
   }
   
 
 
   class SlideTask
     extends TimerTask
   {
     SlideTask() {}
     
 
     public void run()
     {
       if (FSMenuBar.this.m_show) {
         if (FSMenuBar.this.m_slide < 20) {
//           FSMenuBar.access$108(FSMenuBar.this); // TODO tianlin access
           FSMenuBar.this.slide();
         }
         else {
           FSMenuBar.this.m_timer.cancel();
           if (!FSMenuBar.this.m_auto) {
             JViewerApp.getInstance().getRCView().requestFocus();
           }
         }
       }
       else if (FSMenuBar.this.m_slide > 1) {
//         FSMenuBar.access$110(FSMenuBar.this);
         FSMenuBar.this.slide();
       }
       else {
         FSMenuBar.this.m_timer.cancel();
         
         if (FSMenuBar.this.m_auto) {
           JViewerApp.getInstance().getRCView().requestFocus();
         }
       }
     }
   }
   
 
 
   class StatusBarSlideTask
     extends TimerTask
   {
     StatusBarSlideTask() {}
     
 
 
     public void run()
     {
       if (FSMenuBar.this.showLEDStatusBar) {
         if (FSMenuBar.this.slideStatusBar <= 20) {
//           FSMenuBar.access$608(FSMenuBar.this);
           FSMenuBar.this.slideStatusBar();
         }
         else {
           if (FSMenuBar.this.ledStatusTimer != null)
             FSMenuBar.this.ledStatusTimer.cancel();
           if (!FSMenuBar.this.m_auto) {
             JViewerApp.getInstance().getRCView().requestFocus();
           }
         }
       }
       else if (FSMenuBar.this.slideStatusBar >= 1) {
//         FSMenuBar.access$610(FSMenuBar.this);
         FSMenuBar.this.slideStatusBar();
       }
       else {
         if (FSMenuBar.this.ledStatusTimer != null)
           FSMenuBar.this.ledStatusTimer.cancel();
         if (FSMenuBar.this.m_auto) {
           JViewerApp.getInstance().getRCView().requestFocus();
         }
       }
     }
   }
   
 
   class WindowMouseEvents
     extends MouseAdapter
   {
     WindowMouseEvents() {}
     
     public void mouseClicked(MouseEvent paramMouseEvent)
     {
       JViewerApp.getInstance().getRCView().requestFocus();
     }
   }
   
 
 
   class MouseEnterExit
     extends MouseAdapter
   {
     MouseEnterExit() {}
     
 
     public void mouseEntered(MouseEvent paramMouseEvent)
     {
       if (FSMenuBar.this.m_auto) {
         FSMenuBar.this.m_timer.cancel();
         FSMenuBar.this.showMenu();
       }
     }
     
 
 
 
     public void mouseExited(MouseEvent paramMouseEvent)
     {
       if (FSMenuBar.this.m_auto) {
         FSMenuBar.this.m_timer.cancel();
         FSMenuBar.this.hideMenu();
       }
     }
   }
   
 
 
   class PopupListener
     extends MouseAdapter
   {
     PopupListener() {}
     
 
     public void mousePressed(MouseEvent paramMouseEvent)
     {
       Debug.out.println("Popup event");
       FSMenuBar.this.m_popupMenu.show(paramMouseEvent.getComponent(), paramMouseEvent.getX(), paramMouseEvent.getY());
     }
   }
   
 
 
   class PopupMenuEventListener
     implements PopupMenuListener
   {
     boolean m_autoCanceled = false;
     
 
     PopupMenuEventListener() {}
     
     public void popupMenuCanceled(PopupMenuEvent paramPopupMenuEvent)
     {
       Debug.out.println("Popup canceled");
       if (this.m_autoCanceled) {
         FSMenuBar.this.m_auto = true;
         this.m_autoCanceled = false;
       }
     }
     
 
 
 
 
     public void popupMenuWillBecomeVisible(PopupMenuEvent paramPopupMenuEvent)
     {
       Debug.out.println("Popup visible");
       if (FSMenuBar.this.m_auto) {
         FSMenuBar.this.m_auto = false;
         this.m_autoCanceled = true;
       }
     }
     
 
 
 
     public void popupMenuWillBecomeInvisible(PopupMenuEvent paramPopupMenuEvent)
     {
       Debug.out.println("Popup invisible");
       if (this.m_autoCanceled) {
         FSMenuBar.this.m_auto = true;
         this.m_autoCanceled = false;
         FSMenuBar.this.hideMenu();
       }
       JViewerApp.getInstance().getRCView().requestFocus();
     }
   }
   
 
 
   class ButtonListener
     implements ActionListener
   {
     ButtonListener() {}
     
 
     public void actionPerformed(ActionEvent paramActionEvent)
     {
       JViewerApp localJViewerApp = JViewerApp.getInstance();
       String str = paramActionEvent.getActionCommand();
       
       if (str.equals("Unpin")) {
         Debug.out.println("Disable Auto hide");
         FSMenuBar.this.m_autoPanel.removeAll();
         FSMenuBar.this.m_autoPanel.add(FSMenuBar.this.m_autoPin);
         FSMenuBar.this.m_autoPanel.repaint();
         FSMenuBar.this.m_auto = false;
         FSMenuBar.this.ledStatusBar.setAutoHide(false);
         JViewerApp.getInstance().getRCView().requestFocus();
       }
       else if (str.equals("Pin")) {
         Debug.out.println("Enable Auto hide");
         FSMenuBar.this.m_autoPanel.removeAll();
         FSMenuBar.this.m_autoPanel.add(FSMenuBar.this.m_autoUnpin);
         FSMenuBar.this.m_auto = true;
         FSMenuBar.this.ledStatusBar.setAutoHide(true);
         JViewerApp.getInstance().getRCView().requestFocus();
       }
       else if (str.equals(FSMenuBar.TO_FRAME)) {
         Debug.out.println("Toggle to frame window");
         FSMenuBar.this.m_auto = false;
         localJViewerApp.OnVideoFullScreen(false);
       }
       else if (str.equals(FSMenuBar.MINIMIZE)) {
         Debug.out.println("Minimize");
         
         if (JViewer.isStandalone()) {
           JViewer.getMainFrame().setState(1);
         }
       } else if (str.equals(FSMenuBar.CLOSE)) {
         Debug.out.println("Close");
         localJViewerApp.OnVideoExit();
       }
       else if (str.equals(FSMenuBar.MENU)) {
         Debug.out.println("Menu");
       }
       else if (str.equals("LED Status")) {
         JButton localJButton = (JButton)paramActionEvent.getSource();
         if (FSMenuBar.this.showLEDStatusBar) {
           localJButton.setToolTipText(LocaleStrings.getString("B_7_FMB"));
           FSMenuBar.this.showLEDStatusBar(false);
         }
         else {
           localJButton.setToolTipText(LocaleStrings.getString("B_8_FMB"));
           FSMenuBar.this.showLEDStatusBar(true);
         }
         if (FSMenuBar.this.fsToolbarEnabled) {
           FSMenuBar.this.fsToolbarEnabled = false;
         } else {
           FSMenuBar.this.fsToolbarEnabled = true;
         }
       } else {
         JViewerApp.getInstance().getRCView().requestFocus();
       }
     }
   }
 }


/* Location:              D:\Users\tianlin\Downloads\JViewer.jar!\com\ami\kvm\jviewer\gui\FSMenuBar.class
 * Java compiler version: 5 (49.0)
 * JD-Core Version:       0.7.1
 */